#!/usr/bin/env python3

"""标准简单程序的结构"""

import wx


class Frame(wx.Frame):
    """一个用来展示图片的frame"""

    def __init__(self, image, parent=None, pos=wx.DefaultPosition, title="Walden的Demo"):
        """创建Frame实例并显示图片"""
        style = wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX)

        img = image.ConvertToBitmap()
        size = img.GetWidth(), img.GetHeight()
        wx.Frame.__init__(self, parent, -1, title, pos, size, style=style)
        bmp = wx.StaticBitmap(parent=self)
        bmp.SetBitmap(img)


class App(wx.App):
    """Application class"""

    def OnInit(self):
        """初始化App参数, 处理图片"""
        print('OnInit')
        image = wx.Image('ac-camera@3x.png', wx.BITMAP_TYPE_PNG)
        frame = Frame(image)
        frame.Show()
        self.SetTopWindow(frame)
        return True

    def OnExit(self):
        print('Exit app')
        return 0



def main():
    print('before create app')
    app = App(redirect=False)
    print('before mainloop')
    app.MainLoop()
    print('after mainloop')


if __name__ == "__main__":
    main()



